Class NotificationSDKServer
- java.lang.Object
-
- com.vasco.digipass.sdk.utils.notification.server.NotificationSDKServer
-
public class NotificationSDKServer extends java.lang.ObjectProvides the entry points for the NotificationSDKServer library:NotificationSDKServer(NotificationSDKServerCredentials, NotificationSDKServerSettings, NotificationSDKServerCallbacks): contructs the server object;sendNotification(String, Notification): sends a notification to a specific user device;awaitSendTerminationAndFinish(): closes remaining tasks according to the object's settings and eventually closes existing connections;getPayloadLength(Notification, NotificationSDKServerPlatformNames): gets the payload length for a specific notification and platform;getPlatformName(String): gets the platform name of a specific user device (NotificationSDKServerPlatformNames).
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_PAYLOAD_LENGTH_ANDROIDMaximum length, in bytes, of the notification payload for Android as described by the Google Cloud Messaging (GCM) specifications.static intMAX_PAYLOAD_LENGTH_IOSMaximum length, in bytes, of the notification payload for iOS as described by the Apple Push Notification Service (APNS) specifications.static java.lang.StringVERSIONNotificationSDKServer library version
-
Constructor Summary
Constructors Constructor Description NotificationSDKServer(NotificationSDKServerCredentials credentials, NotificationSDKServerSettings settings, NotificationSDKServerCallbacks callbacks)Constructs a NotificationSDKServer object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawaitSendTermination()Wait for all submitted notifications to be sent.voidawaitSendTerminationAndFinish()Wait for all submitted notifications to be sent.static intgetPayloadLength(Notification notification, NotificationSDKServerPlatformNames platformName)Gets the notification payload length, in bytes, depending on the given platform name.static NotificationSDKServerPlatformNamesgetPlatformName(java.lang.String vascoNotificationIdentifier)Gets the platform name from a VASCONotificationIdentifier identified by its hexadecimal representation.voidsendNotification(java.lang.String vascoNotificationIdentifier, Notification notification)Sends a notification, described by a Notification object, using the specified client device identifier.
-
-
-
Field Detail
-
VERSION
public static final java.lang.String VERSION
NotificationSDKServer library version- See Also:
- Constant Field Values
-
MAX_PAYLOAD_LENGTH_ANDROID
public static final int MAX_PAYLOAD_LENGTH_ANDROID
Maximum length, in bytes, of the notification payload for Android as described by the Google Cloud Messaging (GCM) specifications. This constant's value is 4096.- See Also:
- Constant Field Values
-
MAX_PAYLOAD_LENGTH_IOS
public static final int MAX_PAYLOAD_LENGTH_IOS
Maximum length, in bytes, of the notification payload for iOS as described by the Apple Push Notification Service (APNS) specifications. This constant's value is 4096.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NotificationSDKServer
public NotificationSDKServer(NotificationSDKServerCredentials credentials, NotificationSDKServerSettings settings, NotificationSDKServerCallbacks callbacks) throws NotificationSDKServerException
Constructs a NotificationSDKServer object.- Parameters:
credentials- TheNotificationSDKServerCredentialsnecessary to log in to the platform specific push notification services.settings- TheNotificationSDKServerSettingsnecessary to tune server specific settings. Can be null.callbacks- TheNotificationSDKServerCallbacksnecessary to get feedback from the server in case of success/failure of the sending process. Can be null.- Throws:
NotificationSDKServerException- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.SETTINGS_INVALIDif the notification settings is invalid.
-
-
Method Detail
-
getPlatformName
public static NotificationSDKServerPlatformNames getPlatformName(java.lang.String vascoNotificationIdentifier) throws NotificationSDKServerException
Gets the platform name from a VASCONotificationIdentifier identified by its hexadecimal representation.- Parameters:
vascoNotificationIdentifier- Hexadecimal representation of the VASCO notification identifier.- Returns:
- the platform name of VASCONotificationIdentifier (see
NotificationSDKServerPlatformNames). - Throws:
NotificationSDKServerException- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.INTERNAL_ERRORif an internal error occurs.NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_NULLif the identifier is null or empty.NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_INCORRECT_FORMATif the identifier has a wrong format (must be hexadecimal).NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_INVALIDif the identifier is invalid.
-
getPayloadLength
public static int getPayloadLength(Notification notification, NotificationSDKServerPlatformNames platformName) throws NotificationSDKServerException
Gets the notification payload length, in bytes, depending on the given platform name. For all platforms, the payload is encoded in UTF-8 before its length calculation. Therefore, a non-latin character (Cyrillic, Japanese, Arabic, etc.) will have a length greater than 1. Please note that each protocol adds some overhead. The usable length is thus smaller than the theoretical maximum payload length.- Parameters:
notification- notification containing a title, subject...platformName- targeted platform name- Returns:
- The notification payload length in bytes.
- Throws:
NotificationSDKServerException- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.NOTIFICATION_NULLif the notification settings is null.NotificationSDKServerErrorCodes.NOTIFICATION_TITLE_NULLif the notification title is null.NotificationSDKServerErrorCodes.NOTIFICATION_IOS_TITLE_CHARACTER_INVALIDif the notification title contains an invalid character and the notification must be send to an iOS platform.NotificationSDKServerErrorCodes.NOTIFICATION_SUBJECT_NULLif the notification subject is null.NotificationSDKServerErrorCodes.NOTIFICATION_CONTENT_NULLif the notification content is null.
-
sendNotification
public void sendNotification(java.lang.String vascoNotificationIdentifier, Notification notification) throws NotificationSDKServerExceptionSends a notification, described by a Notification object, using the specified client device identifier.As the process of sending a notification is asynchronous, a callback is necessary in order to handle errors or to report success.
- Parameters:
vascoNotificationIdentifier- VASCO notification identifier provided by the client. String, cannot be null or empty.notification- Notification that must be sent to the device (checkNotification).- Throws:
NotificationSDKServerException- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.INTERNAL_ERRORif an internal error occurred.NotificationSDKServerErrorCodes.CALL_ON_TERMINATED_INSTANCEif the object instance has been finished prior to the call.NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_NULLif the notification identifier is null.NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_INCORRECT_FORMATif the identifier has a wrong format (must be hexadecimal).NotificationSDKServerErrorCodes.VASCO_NOTIFICATION_IDENTIFIER_INVALIDif the notification identifier is invalid.NotificationSDKServerErrorCodes.CREDENTIALS_NULLif the credentials object is null.NotificationSDKServerErrorCodes.CREDENTIALS_ANDROID_INVALIDif the Android part of the credentials object is invalid.NotificationSDKServerErrorCodes.CREDENTIALS_IOS_INVALIDif the iOS part of the credentials object is invalid.NotificationSDKServerErrorCodes.NOTIFICATION_NULLif the notification settings is null.NotificationSDKServerErrorCodes.NOTIFICATION_TITLE_NULLif the notification title is null.NotificationSDKServerErrorCodes.NOTIFICATION_IOS_TITLE_CHARACTER_INVALIDif the notification title contains an invalid character and the notification must be send to an iOS platform.NotificationSDKServerErrorCodes.NOTIFICATION_IOS_NO_APP_BUNDLE_IDif no application bundle ID has been set.NotificationSDKServerErrorCodes.NOTIFICATION_SUBJECT_NULLif the notification subject is null.NotificationSDKServerErrorCodes.NOTIFICATION_CONTENT_NULLif the notification content is null.NotificationSDKServerErrorCodes.NOTIFICATION_ANDROID_DATA_TOO_LONGif the Android data of the notification is too long.NotificationSDKServerErrorCodes.NOTIFICATION_IOS_DATA_TOO_LONGif the iOS data of the notification is too long.NotificationSDKServerErrorCodes.NOTIFICATION_PROVIDER_ANDROID_ERRORif there has been an error with the Google notification service provider.NotificationSDKServerErrorCodes.NOTIFICATION_PROVIDER_IOS_ERRORif there has been an error with the Apple notification service provider.
-
awaitSendTermination
public void awaitSendTermination() throws java.lang.InterruptedException, NotificationSDKServerExceptionWait for all submitted notifications to be sent.The last notifications that have not been sent after a specific timeout (which is specified in the
NotificationSDKServerSettingsobject of the NotificationSDKServer object) will be cancelled.All connections are restarted.
- Throws:
java.lang.InterruptedException- if the thread has been interrupted while waiting for the termination of the existing tasks.NotificationSDKServerException- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.CALL_ON_TERMINATED_INSTANCEif the object instance has been finished prior to the call.
-
awaitSendTerminationAndFinish
public void awaitSendTerminationAndFinish() throws java.lang.InterruptedException, NotificationSDKServerExceptionWait for all submitted notifications to be sent.The last notifications that have not been sent after a specific timeout (which is specified in the
NotificationSDKServerSettingsobject of the NotificationSDKServer object) will be cancelled.All connections are closed. The object is not usable anymore and thus can't be used to send notifications.
- Throws:
java.lang.InterruptedException- if the thread has been interrupted while waiting for the termination of the existing tasks.NotificationSDKServerException- Exception containing an error code and a message. Available error codes are:NotificationSDKServerErrorCodes.CALL_ON_TERMINATED_INSTANCEif the object instance has been finished prior to the call.
-
-